package org.hhf.ai.tools.function;

import com.fasterxml.jackson.databind.JsonNode;
import lombok.extern.slf4j.Slf4j;
import org.hhf.ai.tools.funcalling.FunctionTool;
import org.hhf.ai.tools.pojo.Parameters;
import org.hhf.ai.tools.pojo.ToolParamProperties;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

@Slf4j
@Component("today_visit_summary")
public class TodayVisitSummary implements FunctionTool {
    @Override
    public String description() {
        return "这是一个获取当天用户拜访数据的函数";
    }

    @Override
    public Parameters parameters() {
        ToolParamProperties dateProp = new ToolParamProperties();
        dateProp.setType("date");
        dateProp.setDescription("a date");

        ToolParamProperties userProp = new ToolParamProperties();
        userProp.setType("int");
        userProp.setDescription("a number");

        Map<String, ToolParamProperties> props = new HashMap();
        props.put("today", dateProp);
        props.put("user", userProp);


        Parameters params = new Parameters();
        params.setProperties(props);
        params.setRequired(Arrays.asList("today","user"));

        return params;
    }

    @Override
    public String execute(JsonNode params) {
        log.info("函数{}入参：{}", getClass().getName(), params.asText());
        return "{\"storeId\":\"1681960794787430402\",\"storeName\":\"GT门店005\",\"storeCode\":\"winctest055\",\"storeAddr\":\"望京烟酒茶专卖(望馨商业中心店)\",\"imgId\":\"group1/M00/07/56/wKgG0WS_PfiAVa7xAAI-vfjGYf0650.jpg\",\"lon\":\"116.35873413085938\",\"lat\":\"40.051639556884766\",\"channelId\":\"1681528517833437185\",\"channelName\":\"农贸店（菜市场店）\",\"channelCode\":\"GT\",\"typeId\":\"1681526817466789890\",\"typeName\":\"GT\",\"typeCode\":\"00501007\",\"visitId\":\"1871386259381329922\",\"userId\":\"1681924097315708929\",\"visitUserName\":\"测试代表01\",\"bizDate\":\"2025-02-27\",\"inTime\":\"2025-02-27 10:43:40\",\"inLat\":\"40.0515\",\"inLon\":\"116.35806\",\"inAddr\":\"北京市北京市海淀区东升镇科学城中关村东升科学城(东区)\",\"inImgUrl\":\"group1/M00/00/74/wKgG_WdqH-OAJxy5AAFl0AMy7LI418.jpg\",\"outTime\":\"2025-02-27 23:59:59\",\"traceId\":\"V-ON-168192409731570892916819607947874304021735008216458\",\"storeTimes\":\"796\"}\n" +
                "{\"storeId\":\"1681960792950325250\",\"storeName\":\"NKA门店003\",\"storeCode\":\"winctest033\",\"storeAddr\":\"广联超市(韩庄路店)\",\"imgId\":\"group1/M00/07/85/wKgG0WTIc9eABjp0AAIzRwJ0CUY014.jpg\",\"lon\":\"116.35762\",\"lat\":\"40.04279\",\"typeId\":\"1681526817651339265\",\"typeName\":\"NKA\",\"typeCode\":\"00501008\",\"visitId\":\"1871393358379261954\",\"userId\":\"1681925309184352257\",\"visitUserName\":\"测试代表03\",\"bizDate\":\"2025-02-27\",\"inTime\":\"2025-02-27 11:11:51\",\"inLat\":\"40.05242919921875\",\"inLon\":\"116.35908508300781\",\"inAddr\":\"北京市北京市海淀区东升镇中关村东升科学城(东区)\",\"inImgUrl\":\"group1/M00/00/74/wKgG_WdqJn-AdldbAAWcwnIU6Ro616.jpg\",\"outTime\":\"2025-02-27 23:59:59\",\"traceId\":\"V-ON-168192530918435225716819607929503252501735009891114\",\"storeTimes\":\"768\"}。要求：总结中需要有1、KPI的数字指标，如工作时长、在途时长、拜访门店数、拜访达成率、未拜访门店数；2、工作轨迹地图；3、分析建议";
    }
}
